import { isNullOrUndefind } from '../../utils/utils'
const routes = [
  {
    path: '*',
    redirect: '/',
   
  },
  {
    name:'goodsdetail',
    // 大分类
    path: '/goodsdetail/:goodstype/:goodsid/:goodsname',
    component:()=> import('@/views/goodsdetail')
  },
  {
    path: '/register',
    component: ()=>import('@/views/register'),
    beforeEnter: (to, from, next) => {
      // alert('登录')
      // console.log(from);
      // ...
    
      if(isNullOrUndefind(window.sessionStorage.getItem('customer'))&&isNullOrUndefind(window.sessionStorage.getItem('account'))){
        //已登录
        alert('已登录 请先退出后操作')
        next(from)
      }else  if(isNullOrUndefind(window.localStorage.getItem('customer'))&&isNullOrUndefind(window.localStorage.getItem('account'))){
          //
          next('/')
       }else {
        next()
       }
    } 
  },
  {
    path: '/',
    component: ()=>import('@/views/homepage'),
  },
  {
    path: '/fruitsvegetables',
    component: ()=>import('@/views/fruitsvegetables')
  },
  {
    path: '/supplies',
    component: ()=>import('@/views/supplies')
  },
  {
    path: '/dairymeat',
    component: ()=>import('@/views/dairymeat')
  },
  {
    path: '/officeStudy',
    component: ()=>import('@/views/officeStudy')
  },
  {
    path: '/storemap',
    component: ()=>import('@/views/store-map')
  },
  {
    path: '/cart',
    component: ()=>import('@/views/cart'),

  },
  {
    path: '/sundry',
    component: ()=>import('@/views/sundry')
  },
  {
    path: '/cart/checkout',
    component: ()=>import('@/views/checkout')
  }
]

export default routes

